package cn.mengfly.testnrz.im.client.builder;

import cn.mengfly.testnrz.im.ProtoMsg;
import cn.mengfly.testnrz.im.client.ClientSession;
import cn.mengfly.testnrz.im.client.bean.User;

/**
 * 心跳消息构造器
 */
public class HeartBeatMsgBuilder extends BaseBuilder {

    private final User user;

    public HeartBeatMsgBuilder(User user, ClientSession clientSession) {
        super(ProtoMsg.HeadType.KEEPALIVE_REQUEST, clientSession);
        this.user = user;
    }

    public ProtoMsg.Message buildMsg() {
        ProtoMsg.Message message = buildCommon(-1);
        ProtoMsg.MessageHeartBeat.Builder lb = ProtoMsg.MessageHeartBeat.newBuilder()
                .setSeq(0).setJson("{\"from\":\"client\"}").setUid(user.getUid());
        return message.toBuilder().setHeartBeat(lb).build();
    }
}
